﻿
<MudMenu Icon="@Icons.Material.Outlined.Translate" Color="Color.Inherit" 
        AnchorOrigin="Origin.BottomCenter" TransformOrigin="Origin.BottomCenter" Dense="true">
    @foreach (var item in LanguageService.GetSupportedLanguages())
    { 
        <MudMenuItem OnClick="(()=> ChangeLanguageAsync(item))">@LanguageService.ToDisplayString(item)</MudMenuItem>
    }
</MudMenu>

@code {

    private async Task ChangeLanguageAsync(LanguageModel SelectedLanguage)
    {
        await LocalStorage.SetAsync<LanguageModel>(StorageDefaultValue.CultureStorage, SelectedLanguage);
        Navigation.NavigateTo(Navigation.Uri, forceLoad: true);
    }
}

    @*
//CultureInfo culture = new CultureInfo("fa-IR");
//CultureInfo culture = new CultureInfo("en-US");
//var js = host.Services.GetRequiredService<IJSRuntime>();
//var result = await js.InvokeAsync<string>("AppLocalStorage.get", "CultureStorage");
//if (result != null)
//{
//    culture = new CultureInfo(result);
//}
//else 
//{
//    await js.InvokeVoidAsync("AppLocalStorage.set", "CultureStorage", "en-US");
//}
//CultureInfo.DefaultThreadCurrentCulture = culture;
//CultureInfo.DefaultThreadCurrentUICulture = culture;*@